﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace Topcoder
{
    namespace SRM533
    {
        class PikachuEasy
        {
            public static string check(string word)
            {
                string tmp = word;
                tmp = tmp.Replace("pi", ".");
                tmp = tmp.Replace("ka", ".");
                tmp = tmp.Replace("chu", ".");
                tmp = tmp.Replace(".", "");
                if (tmp == "") return "YES";
                else return "NO";
            }
        }

        class CasketOfStarEasy
        {
            public static int maxEnergy(int[] weight)
            {
                count(new List<int>(weight), 0);
                return max;
            }
            static int max = 0;
            public static void count(List<int> a, int pre)
            {
                if (a.Count == 3)
                {
                    max = Math.Max(a[0] * a[2] + pre,max);                    
                    return;
                }
                else
                {
                    for (int i = 1; i < a.Count - 1; i++)
                    {
                        List<int> t = new List<int>(a);
                        t.RemoveAt(i);
                        count(t, pre + a[i - 1] * a[i + 1]);
                    }
                }
            }
        }
    }
}
